package com.bartender.web.controller.wx;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.bartender.common.core.domain.AjaxResult;
import com.bartender.framework.web.service.WxLoginService;
import com.bartender.common.core.domain.wx.WxLoginRequest;
import com.bartender.common.core.domain.wx.WxUserInfo;

@RestController
@RequestMapping("/wx")
@CrossOrigin(origins = "*", maxAge = 3600)
public class WxAuthController {

    @Autowired
    private WxLoginService wxLoginService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody WxLoginRequest request) {
        String token = wxLoginService.login(request.getCode());
        return AjaxResult.success("登录成功", token);
    }

    @PostMapping("/updateUserInfo")
    public AjaxResult updateUserInfo(@RequestBody WxUserInfo userInfo) {
        wxLoginService.updateUserInfo(userInfo);
        return AjaxResult.success();
    }
} 